package com.youngwang.lambda;

import com.youngwang.lambda.infa.Formula;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author youngwang
 *         Date: 2016/10/13
 */
public class FormulaTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ExecutorService executor = Executors.newFixedThreadPool(5);

        Formula formula = new Formula() {
            @Override
            public double calculate(int number) {
                return sqrt(number);
            }
        };

        double result = formula.calculate(16);

        Future<Integer> future = executor.submit(() -> System.out.println(result), 3);
        if (future.isDone())
            System.out.println(future.get());
        double result2 = Formula.pow(result);

        executor.execute(() -> System.out.println(result2));
    }

}
